﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.TeamFoundation.SourceControl.WebApi;
using Microsoft.VisualStudio.Services.Common;

namespace TfsMonitorApp
{
   public class Program
    {

        //给我一个目录，我就能找到这个目录下的所有文件
        public static List<string> GetFilesInDirectory(string directoryPath)
        {
            int i=1/0;
            List<string> fileList = new List<string>();
            try
            {
                string[] files = Directory.GetFiles(directoryPath, "*.*", SearchOption.AllDirectories);
                fileList.AddRange(files);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"An error occurred: {ex.Message}");
            }
            return fileList;
        }
        static public  void Main(string[] args)
        {
            string directoryPath = @"C:"; // 替换为您的目录路径
            List<string> files = GetFilesInDirectory(directoryPath);

            // 在这里输出文件列表
            foreach (var file in files)
            {
                Console.WriteLine(file);
            }

            Console.WriteLine("Hello World!");
            Console.WriteLine("Hi!");



            //    Uri serverUrl = new Uri("https://tfs7.it.keysight.com/tfs/Vision2");
            //    VssCredentials credentials = new VssCredentials();

            //    using (TfvcHttpClient tfvcClient = new TfvcHttpClient(serverUrl, credentials))
            //    {
            //        int lastChangeSetId = 0;


            //        //string tfsDirectory = "$/WCSS_Engineering_STE/STE_SOURCE/SOURCE";
            //        //string tfsDirectory = "$/WCSS_Engineering_STE/STE_SOURCE/SOURCE/MUTS";

            //        //string tfsDirectory = "$/WCSS_Engineering_STE/STE_SOURCE/SOURCE/MUTS";

            //        string tfsDirectory = "$/WCSS_Engineering_STE/MU_CALC/Crystal_MU_Functions";




            //        //$/WCSS_Engineering_STE/MU_CALC/Crystal_MU_Functions

            //        //string tfsDirectory = "$/WCSS_Engineering_STE/STE_SOURCE/SOURCE/MUTS/MV_DMMS/NAI_PXIE-4081";




            //        var searchCriteria = new TfvcChangesetSearchCriteria
            //        {
            //            ItemPath = tfsDirectory,
            //            FromId = lastChangeSetId
            //        };
            //        //var changedSets = Task.Run(() => tfvcClient.GetChangesetsAsync(maxCommentLength: 2000, orderby: "id asc", searchCriteria: searchCriteria)).Result;
            //        var changedSets = await tfvcClient.GetChangesetsAsync(maxCommentLength: 2000, orderby: "id asc",
            //            searchCriteria: searchCriteria,
            //             top: 1000);
            //        //var changedSets = tfvcClient.GetChangesetsAsync(maxCommentLength: 2000, orderby: "id asc", searchCriteria: searchCriteria).Result;
            //        var newChangesets = changedSets.Skip(1).ToList();

            //        if (newChangesets.Any())
            //        {
            //            foreach (var changeset in newChangesets)
            //            {
            //                Console.WriteLine($"Changeset ID: {changeset.ChangesetId}, Comment: {changeset.Comment}");
            //                lastChangeSetId = changeset.ChangesetId;
            //            }
            //        }

            //        // 等待一段时间后再次检查
            //        //await Task.Delay(60000); // 1分钟

            //    }
        }
    }
}
